﻿@model IEnumerable<DSAAssignment.Models.PurchaseModel>

@{
    ViewBag.Title = "MyPurchaseProducts";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>MyPurchaseProducts</h2>

<table>
    <tr>
        <th>
            ProductID
        </th>
        <th>
            ProductName
        </th>
        <th>
            WarrantyDate
        </th>
        <th>
           Fault Status
        </th>
        <th>
            Price
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ProductID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ProductName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.WarrantyDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Fault)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Price)
        </td>
        <td>
          @if (item.FaultID == 7 || item.WarrantyDate < DateTime.Now)
                {  
                                     
                    @Html.ActionLink("Report Fault", "ReportProductFaults", new { Controller = "Product", purchID = item.PurchaseId, prodId = item.ProductID })
                }
        </td>
    </tr>
}

</table>
